﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace apiApplication1.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            List<Category> categorys = new List<Category>();
            categorys.Add(new Category
            {
                id = 1,
                name = "数码",
                products = new List<Product>
                {
                 new Product{id=1,name="电脑",price=4999,CategoryId=1},
                 new Product{id=2,name="手机",price=2999,CategoryId=1}
                }
            });

            categorys.Add(new Category
            {
                id = 2,
                name = "生活用品",
                products = new List<Product>
                {
                 new Product{id=3,name="自行车",price=999,CategoryId=2},
                 new Product{id=4,name="摩托车",price=1999,CategoryId=2}
                }
            });
            ViewBag.Category = categorys;


            return View();
        }

        public ActionResult Register()
        {
            return View();
        }
        [HttpPost]
        [ValidateInput(false)]
        public ContentResult Index(FormCollection form)
        {
            return Content(form["content"]);
        }

        public ActionResult List()
        {
            var model = new List<Product>
                {
                 new Product{id=3,name="自行车",price=999,CategoryId=2},
                 new Product{id=4,name="摩托车",price=1999,CategoryId=2}
                };
            return View(model);
        }
    }


}
